<template>
  <div class="components-container">
    <el-form ref="form" :model="form" label-width="150px">
      <h3>文件设置</h3>
      <el-form-item label="浏览文件">
        <el-upload
          class="upload-demo"
          action="https://jsonplaceholder.typicode.com/posts/"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :before-remove="beforeRemove"
          multiple
          :limit="3"
          :on-exceed="handleExceed"
          :file-list="fileList">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
        </el-upload>
      </el-form-item>
      <el-form-item label="检测路面总长度">
        <el-input v-model="form.roadLength"></el-input>
      </el-form-item>
      <el-row>
        <el-col :span="12">
          <el-form-item label="检测路起点位置">
            <el-input v-model="form.startPoint" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="检测路终点位置">
            <el-input v-model="form.endPoint" />
          </el-form-item>
        </el-col>
      </el-row>
      <h3>分析设置</h3>
      <el-row>
        <el-col :span="12">
          <el-form-item label="分析路面起点位置">
            <el-input v-model="form.analyzeStartPoint"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="分析路面终点位置">
            <el-input v-model="form.analyzeEndPoint"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <h3>模式选择</h3>
      <el-form-item label="分段长度">
        <el-input v-model="form.segmentLength"></el-input>
      </el-form-item>
      <h3>图片信息设置</h3>
      <el-row>
        <el-col :span="12">
          <el-form-item label="纵向长度">
            <el-input v-model="form.verticalLength"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="横向长度">
            <el-input v-model="form.horizonLength"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="道路等级">
            <el-input v-model="form.roadLevel"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="路面类型">
            <el-input v-model="form.roadType"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item>
        <el-button type="primary" icon="el-icon-s-data">破损自动分析</el-button>
        <el-button type="primary" icon="el-icon-s-data">破损辅助分析</el-button>
        <el-button type="primary" icon="el-icon-s-data">车辙分析</el-button>
        <el-button type="primary" icon="el-icon-location-information">参数确认</el-button>
        <el-button style="margin-left: 50px" type="primary" icon="el-icon-s-home">返回主页</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>

export default {
  name: 'FileUpload',
  data() {
    return {
      fileList: [{ name: '路面1.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100' }, { name: '路面2.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100' }],
      form: {
        roadLength: '',
        startPoint: '',
        endPoint: '',
        analyzeStartPoint: '',
        analyzeEndPoint: '',
        segmentLength: '',
        verticalLength: '',
        horizonLength: '',
        roadLevel: '',
        roadType: ''
      }
    }
  },
  methods: {
    onSubmit() {
      console.log('submit!')
    },
    handleRemove(file, fileList) {
      console.log(file, fileList)
    },
    handlePreview(file) {
      console.log(file)
    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`)
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`)
    }
  }
}
</script>

<style scoped>
.avatar{
  width: 200px;
  height: 200px;
  border-radius: 50%;
}
</style>

